import react from 'react'
import TableDataBlock from '@/components/TableDataBlock';
import { Row, Col, Button, Space, Tabs, Card } from 'antd';
import { userObj, userObjType } from '@/common/contact'
export default (props) => {
    const { setData, data = [], onOpen } = props
    const getColumns = [
        {
            title: '字段类型',
            dataIndex: 'type',
            render: (e) => {
                return userObjType[e]

            },
        },
        {
            title: '字段',
            dataIndex: 'onlyKey',
            render: (val, record) => {
                if (userObj[val]) {
                    return userObj[val]
                }
                return record.label
            },

        },
        {
            title: '必填',
            dataIndex: 'require',
            render: (val) => {
                if (val) {
                    return '必填'
                }
                return '非必填'
            },

        },]

    return <Row gutter={[12, 12]}>
        <Col offset={2} span={21}>
            <Button onClick={() => onOpen({ show: true, details: data })} type='primary'>+添加字段</Button>
        </Col>
        <Col offset={2} span={21}>
            {data.length > 0 && <TableDataBlock
                cardProps={false}
                pagination={false}
                columns={getColumns}
                rowKey={(record) => `${record.id}`}
                list={data}
            ></TableDataBlock>
            }
        </Col>
    </Row>
}